<%@page import="com.bgybmi.entity.MeetCreate"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>

	<head>
		<title>我的日程</title>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="format-detection" content="telephone=no">
		<meta name="description" content="北京规划院 移动办公 OA 自动化">
		<link rel="stylesheet" href="//cdn.bootcss.com/weui/1.1.1/style/weui.min.css">
		<link rel="stylesheet" href="//cdn.bootcss.com/jquery-weui/1.1.1/css/jquery-weui.min.css">
		<link rel="stylesheet" href="${base}/css/font-awesome-4.7.0/css/font-awesome.css" />
		<%
		    String userid=(String)request.getAttribute("loginuser");		   
			List<MeetCreate> rcli=(List)request.getAttribute("rcli");
		%>
		<style type="text/css">
			html,
			body {
				font-size: 14px;
			}
			
			.layui-laydate,
			.layui-laydate-main,
			.layui-laydate-content table {
				width: 100% !important;
			}
			
			.select {
				background-color: #9ED99D;
			}
		</style>
	</head>

	<body>
		<div class="layui-inline" id="test-n1"></div>
		<div class="weui-panel">
			<div class="weui-panel__hd">事务列表</div>
			<div class="weui-panel__bd" id="meetlist">
			</div>
		</div>
		<script src="${base}/js/jquery-1.11.3.js" type="text/javascript" charset="utf-8"></script>
		<script src="${base}/js/jquery-weui.min.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			var data = new Array();
			<%
			   for(int i=0;i<rcli.size();i++){
            %>
			data[<%=i%>] = <%=rcli.get(i).toJson()%>;
			<%
			   }
			%>
		</script>
		<script src="${base}/js/laydate/laydate.js"></script>
		<script>
			function meetlist() {
				var day = $('.layui-this').attr("lay-ymd").split("-")[2];
				var month = $('.layui-this').attr("lay-ymd").split("-")[1];
				var year = $('.layui-this').attr("lay-ymd").split("-")[0];
				var html = '';
				for(var i = 0; i < data.length; i++) {
					var a = getday(data[i].starttime)
					if(a[0] == "0") {
						a = a[1]
					}
					var b = getmonth(data[i].starttime)
					if(b[0] == "0") {
						b = b[1]
					}
					var c = getyear(data[i].starttime)
					var hour1 = gethour(data[i].starttime)
					var hour2 = gethour(data[i].finishtime)
					if(a == day && b == month && c == year) {
						html += '<div class="weui-media-box weui-media-box_text" data-xh=' + data[i].xh + '>'
						html += '<h4 class="weui-media-box__title">' + data[i].topic + '</h4>'
						html += '<p class="weui-media-box__desc">' + data[i].meetbz + '</p>'
						html += '<ul class="weui-media-box__info">'
						html += '<li class="weui-media-box__info__meta">' + data[i].room + '</li>'
						html += '<li class="weui-media-box__info__meta">' + hour1 + '~' + hour2 + '</li>'
						html += '<li class="weui-media-box__info__meta weui-media-box__info__meta_extra" >查看详情</li></ul></div>'
					}
				}
				$("#meetlist").html(html)
			}

			function selecday() {
				setTimeout(function() {
					for(var i = 0; i < data.length; i++) {
						var a = getday(data[i].starttime)
						if(a[0] == "0") {
							a = a[1]
						}
						var b = getmonth(data[i].starttime)
						if(b[0] == "0") {
							b = b[1]
						}
						var c = getyear(data[i].starttime)
						if($('[lay-ymd="' + c + '-' + b + '-' + a + '"]').hasClass("laydate-day-next") || $('[lay-ymd="' + c + '-' + b + '-' + a + '"]').hasClass("laydate-day-prev")) {

						} else {
							$('[lay-ymd="' + c + '-' + b + '-' + a + '"]').css('background', "#00F7DE")
						}
					}
				}, 100)
			}

			function getday(time) {
				var a = time.slice(0, 10).split("-");
				return a[2]
			}

			function getmonth(time) {
				var a = time.slice(0, 10).split("-");
				return a[1]
			}

			function getyear(time) {
				var a = time.slice(0, 10).split("-");
				return a[0]
			}

			function gethour(time) {
				var a = time.slice(11)
				return a
			}
			function parseURL(url) {
				if(url.indexOf("?") == -1) return
				var url = url.split("?")[1];
				var res = [];
				if(url.indexOf("&") == -1) {
					var arr = url.split("=");
					res[arr[0]] = arr[1]
				} else {
					var arr = url.split("&");
					for(var i = 0; i < arr.length; i++) {
						var key = arr[i].split("=");
						res[key[0]] = key[1]
					}
				}
				return res

			}
			//执行一个laydate实例
			//直接嵌套显示
			laydate.render({
				elem: '#test-n1',
				position: 'static',
				showBottom: false,
				ready: function(date) {
					setTimeout(function() {
						var url2 = window.location.href;
						url2 = decodeURIComponent(url2);
						var res = parseURL(url2);
						if(res!=undefined&&res.time!= "" && res.time!= undefined) {
							var time = res.time;
							var a = getday(time)
							if(a[0] == "0") {
								a = a[1]
							}
							var b = getmonth(time)
							if(b[0] == "0") {
								b = b[1]
							}
							var c = getyear(time)
							$("td").removeClass("layui-this")
							$('[lay-ymd="' + c + '-' + b + '-' + a + '"]').addClass('layui-this')
						}
						selecday()
						meetlist()
					},100)

				},
				change: function(value, date, endDate) {
					selecday()
					meetlist()
				}
			});


			$("#meetlist").on("click", ".weui-media-box", function() {
				var xh = $(this).attr("data-xh");
				var href = "${base}/meet/meetinfo?xh=" + xh;
				location.href = href
			})
		</script>
	</body>

</html>